<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Promise test</title>
</head>
<body>
    <!-- <script>
        var promise = new Promise(function (resolve, reject) {
            resolve(1000)
        })

        // var p1= promise.then(function(value) {
        //     console.log(value)
        //     return p1
        // })

        // p1.then(function () {}, function(reason) {
        //     console.log(reason.message)
        // })
        promise
            .then(value =>value)
            .then(value =>value)
            .then(value => console.log(value))
    </script> -->

    <script>
        function p1 () {
            return new Promise(function (resolve, reject) {
                setTimeout(function() {
                    resolve('p1')
                }, 2000)
            })
        }
        function p2() {
            return new Promise(function(resolve, reject) {
                // resolve('p2')
            })
        }
        // Promise.all(['a', 'b', p1(), p2(), 'c'])
        //     .then(function (result) {
        //         console.log(result)
        //     })

        // Promise.resolve(100).then(value => console.log(value))
        // Promise.resolve(p1()).then(value => console.log(value))

        p2().finally(() =>{
            cosnole.log('finally')
        })
        .then(value => {
            console.log(value)
        }, reason => {
            console.log(reason)
        })
    </script>
</body>
</html>